<%@ page language="java" contentType="text/html; charset=UTF-8"
		 pageEncoding="UTF-8"%>
<%@include file="../../../common/common.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<title>云众科技网上预约挂号系统</title>
</head>

<body>
<div class="main-container" id="main-container">
	<!-- /section:basics/sidebar -->
	<div class="main-content">
		<div class="main-content-inner">
			<div class="page-content">
				<div class="row">
					<div class="col-xs-12">

						<!-- 检索  -->
						<form  method="post" name="infoForm" action="/baseinfo/listAnnouncement">
							<div class="container">
								<div class="col-sm-4" style="margin-top: 20px;">
									<div class="input-group">
										<input type="text" class="form-control" autocomplete="off" name="noticeTitle" placeholder="请输入公告标题" value="${pd.noticeTitle }">
										<div class="input-group-btn">
											<button type="button" class="btn btn-warning" onclick="doSearch()"><span class="glyphicon glyphicon-search"></span></button>
										</div>
									</div>
								</div>
								<div class="col-sm-6"></div>
								<div class="col-sm-2" style="margin-top: 20px;">
									<div class="form-group">
										<button type="button" class="btn btn-primary" title="增加" onclick="addpage()"><span class="glyphicon glyphicon-plus"></span></button>
										<button type="button" class="btn btn-danger" title="批量删除" onclick="del()"><span class="glyphicon glyphicon-trash"></span></button>
									</div>
								</div>
							</div>
							<table id="simple-table" class="table table-striped table-hover" style="margin-top:5px;">
								<thead>
								<tr class="bg-primary">
									<td align="center"><a href="javascript:selectAll()"><font style="color: white;">全选</font></a></td>
									<td align="center">序号</td>
									<td align="center">公告标题</td>
									<td align="center">公告内容</td>
									<td align="center">公告时间</td>
									<td align="center">操作</td>
								</tr>
								</thead>

								<tbody>
								<!-- 开始循环 -->
								<c:choose>
									<c:when test="${not empty page.list}">
										<c:forEach items="${page.list}" var="department" varStatus="i">
											<tr>
												<td align="center"><input type="checkbox" name="ids" value="${department.noticeId}"></td>
												<td align="center">${(page.pageNum-1)*page.pageSize+i.count}</td>
												<td align="center">${department.noticeTitle}</td>
												<td align="center">${department.noticeContent}</td>
												<td><fmt:formatDate value="${department.noticeTime }" pattern="yyyy年MM月dd日"/></td>
												<td  align="center">
													<button type="button" class="btn btn-primary" title="修改" onclick="editpage('${department.noticeId}')"><span class="glyphicon glyphicon-edit"></span></button>
													<button type="button" class="btn btn-danger" title="删除" onclick="delOne('${department.noticeId}')"><span class="glyphicon glyphicon-minus"></span></button>
													<%--<button type="button" class="btn btn-primary" title="增加" onclick="addpage()"><span class="glyphicon glyphicon-plus"></span></button>--%>
												</td>
											</tr>
										</c:forEach>
									</c:when>
									<c:otherwise>
										<tr class="main_info">
											<td colspan="100" class="center" >没有相关数据</td>
										</tr>
									</c:otherwise>
								</c:choose>
								</tbody>
							</table>
							<div align="center">
								<yzpage:page pageName="page" url="/baseinfo/listAnnouncement"></yzpage:page>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
</body>
<script type="text/javascript">
	function editpage(id){
		location.href = "/baseinfo/editAnnouncement?id="+id + "&pageNum=${pd.pageNum}";
	}
	function addpage(){
		location.href = "/baseinfo/addAnnouncement";
	}
	function delOne(id){
		bootbox.confirm("确定要删除吗?", function(result) {
			if(result){
				location.href = "/baseinfo/removeAnnouncement?ids="+id;
			}
		})
	}

	function doSearch(){
		$("form[name='infoForm']").attr("action","/baseinfo/listAnnouncement");
		$("form[name='infoForm']").submit();
	}
	//全选
	function selectAll(){
		var ipts;
		if("${page!=null}"=="true"){
			inpts = $("form[name='departmentForm'] input[name='ids']");
		}else{
			inpts = $("form[name='departmentTypeForm'] input[name='ids']");
		}
		var inpts = $("input[name='ids']");
		for(var i=0;i<inpts.length;i++){
			if(inpts[i].checked!=true){
				inpts[i].checked=true;
			}else{
				inpts[i].checked=false;
			}
		}
	}

	//批量操作
	function del(){
		bootbox.confirm("'确定要删除选中的数据吗?", function(result) {
			if(result) {
				var checked = $("form[name='infoForm'] :input:checked");

				if(checked.length==0){
					bootbox.dialog({
						message: "<span class='bigger-110'>您没有选择任何内容!</span>",
						buttons:
								{ "button":{ "label":"确定", "className":"btn-sm btn-success"}}
					});
					$("#zcheckbox").tips({
						side:1,
						msg:'点这里全选',
						bg:'#AE81FF',
						time:8
					});
					return;
				}else{
					$("form[name='infoForm']").attr("action","/baseinfo/removeAnnouncement");
					$("form[name='infoForm']").submit();
				}
			}
		});
	};
</script>
</html>